package com.timber.util;

import java.sql.*;


public class ITPPBAllocation extends SLDataObjectAdaptor
{
  private String tradeEntryUI;
  private String intercoInd;
  private String viewpoint;
  private String costCenterAllocation;
  private String specialInd;
  private String pbStreetsideState;
  private String allocationState;
  private String comments;


  public static final String KEY_UI_TE_STANDARD           = "TE_STD";
  public static final String KEY_UI_TE_CHAINED_INTERCO    = "TE_CI";
  public static final String KEY_UI_CHAINED_INTERCO       = "CI";

  public static final String KEY_VIEWPOINT_ENTITY         = "E";
  public static final String KEY_VIEWPOINT_CPTY           = "C";

  public static final String KEY_CC_ALLOCATION_MANUAL     = "M";
  public static final String KEY_CC_ALLOCATION_AUTO       = "A";
  public static final String KEY_CC_ALLOCATION_NONE       = "N";

  public static final String FUNCTION_ENABLED         = "E";
  public static final String FUNCTION_DISABLED        = "D";
  public static final String FUNCTION_INVALID         = "I";

  public static final String HASH_DELIM               = ":";

  public static final String TRADE_ENTRY_UI         = "TradeEntryUI";
  public static final String INTERCO_IND            = "IntercoInd";
  public static final String VIEWPOINT              = "Viewpoint";
  public static final String COST_CENTER_ALLOCATION  = "CostCenterAllocation";
  public static final String SPECIAL_IND            = "SpecialInd";
  public static final String PB_STREETSIDE_STATE    = "PBStreetsideState";
  public static final String ALLOCATION_STATE       = "AllocationState";
  public static final String COMMENTS               = "Comments";


  public boolean load(ResultSet rs) throws SQLException
  {
    tradeEntryUI          = rs.getString( TRADE_ENTRY_UI );
    intercoInd            = rs.getString( INTERCO_IND );
    viewpoint             = rs.getString( VIEWPOINT );
    costCenterAllocation  = rs.getString( COST_CENTER_ALLOCATION );
    specialInd            = rs.getString( SPECIAL_IND );
    pbStreetsideState     = rs.getString( PB_STREETSIDE_STATE );
    allocationState       = rs.getString( ALLOCATION_STATE );
    comments              = rs.getString( COMMENTS );

    return true;

  }

  public String getTradeEntryUI()         { return tradeEntryUI;}

  public String getIntercoInd()           { return intercoInd;}

  public String getViewpoint()            { return viewpoint;}

  public String getCostCenterAllocation() { return costCenterAllocation;}

  public String getSpecialInd()           { return specialInd;}

  public String getPBStreetsideState()    { return pbStreetsideState;}

  public String getAllocationState()      { return allocationState;}

  public String getComments()             { return comments;}


  public static boolean isFunctionValid(String f)
  {
      if (f.equals(PB_STREETSIDE_STATE) )     { return true; }
      if (f.equals(ALLOCATION_STATE) )        { return true; }

      return false;
  }

  public Object hashKey()
  {
      StringBuffer hk = new StringBuffer();

      hk.append( tradeEntryUI);
      hk.append( HASH_DELIM);
      hk.append( intercoInd);
      hk.append( HASH_DELIM);
      hk.append( viewpoint);
      hk.append( HASH_DELIM);
      hk.append( costCenterAllocation);
      hk.append( HASH_DELIM);
      hk.append( specialInd);

      return   hk.toString();
  }

  public String toString()
  {
      StringBuffer printObj = new StringBuffer();

      printObj.append( TRADE_ENTRY_UI + ":" + tradeEntryUI + "\n");
      printObj.append( INTERCO_IND + ":" + intercoInd + "\n");
      printObj.append( VIEWPOINT + ":" + viewpoint + "\n");
      printObj.append( COST_CENTER_ALLOCATION + ":" + costCenterAllocation + "\n");
      printObj.append( SPECIAL_IND + ":" + specialInd + "\n");
      printObj.append( PB_STREETSIDE_STATE + ":" + pbStreetsideState + "\n");
      printObj.append( ALLOCATION_STATE + ":" + allocationState + "\n");
      printObj.append( COMMENTS + ":" + comments + "\n");

      return   printObj.toString();

  }

}
